<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
        <title>Hyphenator.js &ndash; Test 120</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <style type="text/css">
            body {
                width:50%;
                margin-left:25%;
                margin-right:25%;
            }
            h2 + p {
                background-color: #ffd6d6;
            }
            h2 + p + p {
                background-color: #d6ffd6;
            }
        </style>
        <script src="../Hyphenator.js" type="text/javascript"></script>
        <script type="text/javascript">
            if (parent != window) {
                Hyphenator.config({
                    'onhyphenationdonecallback': function () {
                        var i, last = 4, t1, t2, r = true,
                        desc = document.getElementById('desc').firstChild.data,
                        msg = {
                            desc: desc,
                            index: 120
                        };
                        for (i = 1; i <= last; i++) {
                            t1 = document.getElementById('test' + i).innerText;
                            t2 = document.getElementById('ref' + i).innerText;
                            r = r && (t1 == t2);
                        }
                        if (r) {
                            msg.result = 'passed';
                        } else {
                            msg.result = 'failed';
                        }
                        parent.postMessage(JSON.stringify(msg), window.location.href);
                    }
                });         
            }

            Hyphenator.config({
                hyphenchar: '|',
                safecopy: false,
                selectorfunction: function () {
                    var classNames = ["text", "content", "blocktext"],
                        elements2hyphenate = [];
                    classNames.forEach(function (c) {
                        var elementsOfClass = document.getElementsByClassName(c);
                        Array.prototype.forEach.call(elementsOfClass, function (e) {
                            elements2hyphenate.push(e);
                        });
                    });
                    return elements2hyphenate;
                }
            });
            Hyphenator.run();
        </script>
    </head>
    <body>
        <p><a href="index.html">&lt;&lt;- index</a> | <a href="test119.html">&lt;- Prev</a> | <a href="test121.html">Next -&gt;</a></p>
        <h1>Test 120</h1>
        <p id="desc">Use multiple class names</p>

        <h2>Class "text"</h2>
        <p id="test1" class="text">Hyphenation</p>
        <p id="ref1">Hy|phen|ation</p>

        <h2>Class "content"</h2>
        <p id="test2" class="content">Hyphenation</p>
        <p id="ref2">Hy|phen|ation</p>

        <h2>Class "blocktext"</h2>
        <p id="test3" class="blocktext">Hyphenation</p>
        <p id="ref3">Hy|phen|ation</p>

        <h2>Nested classes</h2>
        <p id="test4" class="content">Hyphenation <span class="text">Example</span></p>
        <p id="ref4">Hy|phen|ation <span>Ex|am|ple</span></p>
    </body>
</html>